package com.turato.method;


import com.turato.method.model.DeliveryStateEnum;
import com.turato.method.model.bo.OrderBO;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * @author tuhao
 * @date 2021/2/7 10:55 下午
 * @desc
 */
public class RemoveFlagArgument {

    public Date deliveryDate(OrderBO anOrder, Boolean isRush) {
        // 是否加急
        if (isRush) {
            // 天
            int deliveryTimeDay = 0;
            if (DeliveryStateEnum.ORDERED.getState().equals(anOrder.getDeliveryState())) {
                deliveryTimeDay = 1;
            } else if (DeliveryStateEnum.PREPARED.getState().equals(anOrder.getDeliveryState())) {
                deliveryTimeDay = 2;
            }
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(anOrder.getPlacedOn());
            // 日期往后推N天
            calendar.add(Calendar.DATE, deliveryTimeDay + 1);
            return calendar.getTime();
        } else {
            // 天
            int deliveryTimeDay = 1;
            if (DeliveryStateEnum.ORDERED.getState().equals(anOrder.getDeliveryState())) {
                deliveryTimeDay = 2;
            } else if (DeliveryStateEnum.PREPARED.getState().equals(anOrder.getDeliveryState())) {
                deliveryTimeDay = 3;
            }
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(anOrder.getPlacedOn());
            // 日期往后推N天
            calendar.add(Calendar.DATE, deliveryTimeDay + 2);
            return calendar.getTime();
        }
    }

}
